<% layout('/layouts/default.html', {title: '设备列表', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('设备列表')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('test:equipInfo:edit')){ %>
					<a href="${ctx}/test/equipInfo/form" class="btn btn-default btnTool" title="${text('新增equip_info')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${equipInfo}" action="${ctx}/test/equipInfo/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('设备编号')}：</label>
					<div class="control-inline">
						<#form:input path="equipId" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('设备管理员编号')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="equipManagerCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备管理员')}：</label>
					<div class="control-inline">
						<#form:input path="equipManager" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备名称')}：</label>
					<div class="control-inline">
						<#form:input path="equipName" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备类型')}：</label>
					<div class="control-inline">
						<#form:input path="equipType" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备型号')}：</label>
					<div class="control-inline">
						<#form:input path="equipModel" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('生产厂商')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="manufacture" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备价格')}：</label>
					<div class="control-inline">
						<#form:input path="equipPrice" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('安放地点')}：</label>
					<div class="control-inline">
						<#form:input path="equipPosition" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备所属部门')}：</label>
					<div class="control-inline">
						<#form:input id="testOffice" path="testOffice.officeName" labelPath="testOffice.officeName"  maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备状态')}：</label>
					<div class="control-inline" style="width: 120px;">
						<#form:select path="equipStatus"   blankOption="true" dictType="equip_status" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('购置时间')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="buyTime" class="form-control width-120"/>
					</div>
				</div>

				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('点检计划编号')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="checkPlanCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('巡检计划编号')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="inspectPlanCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('设备使用年限')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="equipLife" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('备注')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="remarks" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden" >${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select:hidden path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label" hidden="hidden">${text('删除标记')}：</label>
					<div class="control-inline">
						<#form:input:hidden path="delFlag" maxlength="1" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('设备编号')}', name:'equipId', index:'a.equip_id', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
                if(row.equipStatus == '0'){
                    row.equipStatus = "正常"
                }else if(row.equipStatus == '1'){
                    row.equipStatus = "报修";
                }else if(row.equipStatus == '3'){
                 	row.equipStatus = "调拨";
                }else{
                    row.equipStatus = "报废";
                }
                row.buyTime  = row.buyTime.substring(0,row.buyTime.length-3);

		    return '<a href="${ctx}/test/equipInfo/form?id='+row.id+'" class="btnList" data-title="${text('编辑equip_info')}">'+(val||row.id)+'</a>';
		}},
		//{header:'${text('设备管理员编号')}', name:'equipManagerCode', index:'a.equip_manager_code', width:150, align:"left"},
		//{header:'${text('设备管理员')}', name:'equipManager', index:'a.equip_manager', width:150, align:"left"},
		{header:'${text('设备管理员')}', name:'testUser.userName', index:'', width:150, align:"left"},
		{header:'${text('设备名称')}', name:'equipName', index:'a.equip_name', width:200, align:"left"},
		{header:'${text('设备类型')}', name:'equipType', index:'a.equip_type', width:100, align:"left"},
		//{header:'${text('设备型号')}', name:'equipModel', index:'a.equip_model', width:150, align:"left"},
		//{header:'${text('生产厂商')}', name:'manufacture', index:'a.manufacture', width:150, align:"left"},
		{header:'${text('设备价格')}', name:'equipPrice', index:'a.equip_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('安放地点')}', name:'equipPosition', index:'a.equip_position', width:150, align:"left"},
		{header:'${text('所属部门')}', name:'testOffice.officeName', index:'', width:150, align:"left"},
		{header:'${text('设备状态')}', name:'equipStatus', index:'a.equip_status', width:100, align:"left"},
	 	//{header:'${text('购置时间')}', name:'buyTime', index:'a.buy_time', width:180, align:"center"},
	 	//{header:'${text('点检计划编号')}', name:'checkPlanCode', index:'a.check_plan_code', width:150, align:"left"},
	 	//{header:'${text('巡检计划编号')}', name:'inspectPlanCode', index:'a.inspect_plan_code', width:150, align:"left"},
		//{header:'${text('设备使用年限')}', name:'equipLife', index:'a.equip_life', width:150, align:"left"},
		//{header:'${text('创建时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		//{header:'${text('备注')}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		//{header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
		// 	return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);
		// }},
		//{header:'${text('删除标记')}', name:'delFlag', index:'a.del_flag', width:150, align:"left"},
		{header:'${text('操作')}', name:'actions', width:170, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('test:equipInfo:edit')){ %>
				 if(row.equipStatus == '报修' || row.equipStatus == '调拨' || row.equipStatus == '报废'){
					<%if(hasPermi('test:equipInfo:view')){%>
                        actions.push('<a href="${ctx}/test/equipInfo/form?id='+row.id+'&opera=view" class="btnList" title="${text('查看设备信息')}"><i class="fa fa-eye"></i></a>&nbsp;');
					<% } %>
			    }else{
					actions.push('<a href="${ctx}/test/equipInfo/form?id='+row.id+'" class="btnList" title="${text('编辑')}"><i class="fa fa-pencil"></i></a>&nbsp;');
					// if (row.status == Global.STATUS_NORMAL){
					// 	actions.push('<a href="${ctx}/test/equipInfo/disable?id='+row.id+'" class="btnList" title="${text('停用equip_info')}" data-confirm="${text('确认要停用该equip_info吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
					// }
					// if (row.status == Global.STATUS_DISABLE){
					// 	actions.push('<a href="${ctx}/test/equipInfo/enable?id='+row.id+'" class="btnList" title="${text('启用equip_info')}" data-confirm="${text('确认要启用该equip_info吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
					// }
					actions.push('<a href="${ctx}/test/equipInfo/delete?id='+row.id+'" class="btnList" title="${text('删除')}" data-confirm="${text('确认要删除该设备吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');

					<% if(hasPermi('test:equipTransferInfo:apply:edit')){ %>
							actions.push('<a href="${ctx}/test/equipTransferInfo/form?equipid='+row.equipId+'" class="btnList" title="${text('调拨')}"><i class="fa fa-arrow-circle-left"></i></a>&nbsp;');
					<% } %>
					<% if(hasPermi('test:equipMaintain:Apply:edit')){ %>
						actions.push('<a href="${ctx}/test/equipMaintainApply/form?equipid='+row.equipId+'" class="btnList" title="${text('报修')}"><i class="fa fa-wrench"></i></a>&nbsp;');
					<% } %>
					<% if(hasPermi('test:equipScrappedInfo:apply:edit')){ %>
						 actions.push('<a href="${ctx}/test/equipScrappedInfo/form?equipid='+row.equipId+'" class="btnList" title="${text('报废')}"><i class="fa fa-soccer-ball-o"></i></a>&nbsp;');
					<% } %>
			    }

            <% } %>


			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>